//+======================================================================
// $Source: $
//
// Project:   	Tango Device Server
//
// Description:	java source code for the Screen class .
//              This class is a singleton class and implements everything
//              which exists only once for all the  Screen object
//              It inherits from the DeviceClass class.
//
// $Author: $
//
// $Revision$
//
// $Log:	$
//
// copyleft :    European Synchrotron Radiation Facility
//               BP 220, Grenoble 38043
//               FRANCE
//
//-======================================================================
//
//  		This file is generated by POGO
//	(Program Obviously used to Generate tango Object)
//
//         (c) - Software Engineering Group - ESRF
//=============================================================================

package Screen;

import java.util.*;
import org.omg.CORBA.*;
import fr.esrf.Tango.*;
import fr.esrf.TangoDs.*;
import fr.esrf.TangoApi.*;

public class ScreenClass extends DeviceClass implements TangoConst
{
	/**
	 *	ScreenClass class instance (it is a singleton).
	 */
	private static ScreenClass	_instance = null;

	//--------- Start of properties data members ----------

	//--------- End of properties data members ----------


//===================================================================			
//
// method : 		instance()
// 
// description : 	static method to retrieve the ScreenClass object 
//					once it has been initialised
//
//===================================================================			
	public static ScreenClass instance()
	{
		if (_instance == null)
		{
			System.err.println("ScreenClass is not initialised !!!");
			System.err.println("Exiting");
			System.exit(-1);
		}
		return _instance;
	}

//===================================================================			
//
// method : 		Init()
// 
// description : 	static method to create/retrieve the ScreenClass
//					object. This method is the only one which enables a 
//					user to create the object
//
// in :			- class_name : The class name
//
//===================================================================			
	public static ScreenClass init(String class_name) throws DevFailed
	{
		if (_instance == null)
		{
			_instance = new ScreenClass(class_name);
		}
		return _instance;
	}
	
//===================================================================			
//
// method : 		ScreenClass()
// 
// description : 	constructor for the ScreenClass class
//
// argument : in : 	- name : The class name
//
//===================================================================			
	protected ScreenClass(String name) throws DevFailed
	{
		super(name);

		Util.out2.println("Entering ScreenClass constructor");
		write_class_property();
	
		Util.out2.println("Leaving ScreenClass constructor");
	}
	
//===================================================================			
//
// method : 		command_factory()
// 
// description : 	Create the command object(s) and store them in the
//					command list
//===================================================================			
	public void command_factory()
	{
		command_list.addElement(new SetTextCmd("SetText",
			Tango_DEV_STRING, Tango_DEV_VOID,
			"the char to print on screen",
			""));
	}


//===================================================================			
//
// method : 		device_factory()
// 
// description : 	Create the device object(s) and store them in the 
//					device list
//
// argument : in : 	String[] devlist : The device name list
//
//===================================================================			
	public void device_factory(String[] devlist) throws DevFailed
	{
	
		for (int i=0 ; i<devlist.length ; i++)
		{
			Util.out4.println("Device name : " + devlist[i]);
						
			// Create device and add it into the device list
			//----------------------------------------------
			device_list.addElement(new Screen(this, devlist[i]));

			// Export device to the outside world
			//----------------------------------------------
			if (Util._UseDb == true)
				export_device(((DeviceImpl)(device_list.elementAt(i))));
			else
				export_device(((DeviceImpl)(device_list.elementAt(i))), devlist[i]);
		}
	}
//===================================================================
/**
 *	Set class description as property in database
 */
//===================================================================			
	private void write_class_property() throws DevFailed
	{	
		//	First time, check if database used
		//--------------------------------------------
		if (Util._UseDb == false)
			return;

		//	Prepeare DbDatum
		//--------------------------------------------
		DbDatum[]	data = new DbDatum[2];
		data[0] = new DbDatum("ProjectTitle");
		data[0].insert("lgm2");

		data[1] = new DbDatum("Description");
		data[1].insert("a simple GUI");

		//	Call database and and values
		//--------------------------------------------
		get_db_class().put_property(data);
	}

}
